package com.wude.guild.imageutil.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.wude.guild.imageutil.R;

/**
 * Created by dxb on 2017/3/27.
 */

public class ShowImageDialog extends Dialog implements View.OnClickListener {
    private Bitmap bitmap;
    private ImageView imageView;

    public ShowImageDialog(Context context, Bitmap bitmap) {
        super(context);
        this.bitmap = bitmap;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);// 去标题栏
        Window window = this.getWindow();
        window.setBackgroundDrawableResource(R.color.window_color);
        window.getDecorView().setPadding(20, 20, 20, 20);
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.MATCH_PARENT;
        // 在手机屏幕下方
        window.setAttributes(lp);
//        window.setGravity(Gravity.CENTER);
        setContentView(R.layout.show_image_dialog);
        imageView = findViewById(R.id.imageView);
        imageView.setImageBitmap(bitmap);

        imageView.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        dismiss();
    }
}
